home *** CD-ROM | disk | FTP | other *** search
/ C & C++ Multimedia Cyber Classroom / C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso / cpphtp2 / code.jar / code / ch11 / fig11_19.txt < prev    next >
Text File  |  1998-02-27  |  1KB  |  32 lines

  1. 1   // Fig. 11.19: fig11_19.cpp 
  2. 2   // Creating and testing user-defined, nonparameterized 
  3. 3   // stream manipulators.
  4. 4   #include <iostream.h>
  5. 5   
  6. 6   // bell manipulator (using escape sequence \\a)
  7. 7   ostream& bell( ostream& output ) { return output << '\\a'; }
  8. 8   
  9. 9   // ret manipulator (using escape sequence \\r)
  10. 10  ostream& ret( ostream& output ) { return output << '\\r'; }
  11. 11  
  12. 12  // tab manipulator (using escape sequence \ )
  13. 13  ostream& tab( ostream& output ) { return output << '\ '; }
  14. 14  
  15. 15  // endLine manipulator (using escape sequence \n
  16. 16  // and the flush member function)
  17. 17  ostream& endLine( ostream& output ) 
  18. 18  { 
  19. 19     return output << '\n' << flush;
  20. 20  }
  21. 21  
  22. 22  int main()
  23. 23  {
  24. 24     cout << "Testing the tab manipulator:" << endLine
  25. 25          << 'a' << tab << 'b' << tab << 'c' << endLine
  26. 26          << "Testing the ret and bell manipulators:"
  27. 27          << endLine << "..........";
  28. 28     cout << bell;
  29. 29     cout << ret << "-----" << endLine;
  30. 30     return 0;
  31. 31  }
  32.